﻿Imports System.Drawing.Drawing2D
Public Class Uhr

    Public Sub tick(ByVal h, ByVal m, ByVal s, ByVal day, ByVal mon, ByVal j)
        If CheckBox1.Checked = True Then
            h = h + 1


        End If
        Label1.Text = (day & "." & mon & "." & "20" & j)
        Me.Text = (h & ":" & m & ":" & s)

        Dim bmp As Bitmap = New Bitmap(310, 310)
        Dim g As Graphics = Graphics.FromImage(bmp)
        Dim gFont As New Font("Comic Sans MS", 20, FontStyle.Bold)
        Dim f1 As Pen = New Pen(Color.BlueViolet, 10)
        Dim f2 As Pen = New Pen(Color.BlueViolet, 3)
        Dim x, y, wi, b As Int32


        f1.EndCap = LineCap.Triangle
        f1.StartCap = LineCap.RoundAnchor
        g.SmoothingMode = Drawing2D.SmoothingMode.HighQuality
        g.TextRenderingHint = _
              Drawing.Text.TextRenderingHint.ClearTypeGridFit
        If h > 12 Then h -= 12
        g.FillEllipse(Brushes.DarkGray, 1, 1, 308, 308)
        g.FillEllipse(Brushes.Silver, 15, 15, 280, 280)
        b = 12
        For wi = 90 To 420 Step 30
            x = CInt(132 + Math.Cos(wi * Math.PI / 180) * 120)
            y = CInt(136 - Math.Sin(wi * Math.PI / 180) * 120)
            If b = 12 Then x -= 7
            g.DrawString(Str(b), gFont, Brushes.Red, x, y)
            b -= 1
        Next wi
        gFont.Dispose()
        For wi = 90 To 450 Step 6
            x = CInt(154 + Math.Cos(wi * Math.PI / 180) * 135)
            y = CInt(154 - Math.Sin(wi * Math.PI / 180) * 135)
            g.FillEllipse(Brushes.BlueViolet, x, y, 3, 3)
        Next wi
        g.TranslateTransform(-155, -155)
        g.RotateTransform(-90 + h * 30 + (m \ 2), MatrixOrder.Append)
        g.TranslateTransform(155, 155, MatrixOrder.Append)
        g.DrawLine(f1, 155, 155, 245, 155)
        g.ResetTransform()
        g.TranslateTransform(-155, -155)
        g.RotateTransform(-90 + m * 6 + (s \ 10), MatrixOrder.Append)
        g.TranslateTransform(155, 155, MatrixOrder.Append)
        f1.Width = 8
        g.DrawLine(f1, 155, 155, 280, 155)
        f1.Dispose()
        g.ResetTransform()
        g.TranslateTransform(-155, -155)
        g.RotateTransform(-90 + s * 6, MatrixOrder.Append)
        g.TranslateTransform(155, 155, MatrixOrder.Append)
        g.DrawLine(f2, 155, 155, 280, 155)
        f2.Dispose()
        g.FillEllipse(Brushes.Red, 147, 147, 16, 16)
        PictureBox1.Image = bmp
    End Sub


    
    Private Sub Uhr_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Me.TopMost = True
    End Sub
End Class